const db = require('../plugin/query');
const dayjs = require('dayjs');

const geRecentDate = async () => {
    try {
        const nowDate = dayjs().format("YYYY-MM-DD");
        console.log(nowDate);
        let sql = `SELECT * FROM oilpriceadjustment WHERE date > '${nowDate}' ORDER BY date LIMIT 1;`;
        const [rows, fields] = await db.query(`${sql}`);
        return {
            code: 1,
            msg: '查询成功',
            data: rows,
        }
    } catch (err) {
        console.error(err);
        return err;
    }
}

module.exports = {
    geRecentDate,
}